| Total Complexity | 1 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 17 | |||
| 18 | @Controller('app/customers') |
||
| 19 | @UseGuards(IsAuthenticatedGuard) |
||
| 20 | export class ListCustomersController { |
||
| 21 | constructor( |
||
| 22 | @Inject('IQueryBus') |
||
| 23 | private readonly queryBus: IQueryBus, |
||
| 24 | private readonly tableFactory: CustomerTableFactory |
||
| 25 | ) {} |
||
| 26 | |||
| 27 | @Get() |
||
| 28 | @WithName('crm_customers_list') |
||
| 29 | @Render('pages/customers/list.njk') |
||
| 30 | public async get(@Query() paginationDto: PaginationDTO) { |
||
| 31 | const pagination: Pagination<CustomerView> = await this.queryBus.execute( |
||
| 32 | new GetCustomersQuery(paginationDto.page) |
||
| 33 | ); |
||
| 34 | |||
| 35 | const table = this.tableFactory.create(pagination.items); |
||
| 36 | |||
| 37 | return { table, pagination, currentPage: paginationDto.page }; |
||
| 38 | } |
||
| 40 |